package com.breezelin.freshmarket.entities.data;

/**
 * Created by Breeze Lin
 * 2016/5/16 09:25
 * breezesummerlin@163.com
 */

import android.os.Parcel;
import android.os.Parcelable;

import com.breezelin.freshmarket.entities.JsonStruct;

import org.json.JSONObject;

/**
 * 产品简略信息
 */
public class ProductShortCut implements JsonStruct, Parcelable {

	/*
	{
            "CategoryId": "b5fff91c-caef-4a8e-a1b4-bc2f44475110",
            "CategoryCode": "0101_qiyiguo",
            "CategoryName": "奇异果",
            "PictureUrl": "http://img02.yiguo.com/e/web/140418/00872/cats/0101_qiyiguo.png",
            "Description": "奇异果"
          }
	 */

	private String categoryId;
	private String categoryCode;
	private String categoryName;
	private String pictureUrl;
	private String description;

	public ProductShortCut() {
	}

	public ProductShortCut(JSONObject jsonObject) {
		fromJson(jsonObject);
	}

	public String getCategoryId() {
		return categoryId;
	}

	public String getCategoryCode() {
		return categoryCode;
	}

	public String getCategoryName() {
		return categoryName;
	}

	public String getPictureUrl() {
		return pictureUrl;
	}

	public String getDescription() {
		return description;
	}

	@Override
	public void fromJson(JSONObject jsonObject) {
		categoryId = jsonObject.optString("CategoryId");
		categoryCode = jsonObject.optString("CategoryCode");
		categoryName = jsonObject.optString("CategoryName");
		pictureUrl = jsonObject.optString("PictureUrl");
		description = jsonObject.optString("Description");
	}

	@Override
	public JSONObject toJson() {
		return new JSONObject();
	}


	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(this.categoryId);
		dest.writeString(this.categoryCode);
		dest.writeString(this.categoryName);
		dest.writeString(this.pictureUrl);
		dest.writeString(this.description);
	}

	protected ProductShortCut(Parcel in) {
		this.categoryId = in.readString();
		this.categoryCode = in.readString();
		this.categoryName = in.readString();
		this.pictureUrl = in.readString();
		this.description = in.readString();
	}

	public static final Parcelable.Creator<ProductShortCut> CREATOR = new Parcelable.Creator<ProductShortCut>() {
		@Override
		public ProductShortCut createFromParcel(Parcel source) {
			return new ProductShortCut(source);
		}

		@Override
		public ProductShortCut[] newArray(int size) {
			return new ProductShortCut[size];
		}
	};
}
